<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
      border-collapse: collapse;
    }
    tr{
      font-size: 0px;
    }
    td{
      width: 50px;
      height: 20px;
      border: 1px solid black;
      border-collapse: collapse;
      /* border-spacing: 0; */
    }
    .bcp{
      background-color: pink;
    }
    .bcr{
      background-color: darkgrey;
    }
    .bcb{
      background-color: blue;
    }
  </style>
</head>
<body>
  <table id="bg">
   <tr>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
   </tr>
   <tr>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
   </tr>
   <tr>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
   </tr>
   <tr>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
   </tr>
   <tr>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
   </tr>
   <tr>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
   </tr>
   <tr>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
   </tr>
   <tr>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
   </tr>
  </table>
  <script>
    var tr= document.querySelectorAll("#bg tr");
    var ta = document.getElementById("bg");
    console.dir(tr);
    for (let index = 0; index < tr.length; index++) {
      if (index % 2 === 0) {
        tr[index].classList.add("bcp")
      }else {
        tr[index].classList.add("bcr")
      }
    }
    for (let index1 = 0; index1 < tr.length; index1++) {
      tr[index1].onmouseover = function () {
        for (let index2 = 0; index2 < tr.length; index2++) {
          tr[index2].classList.remove("bcb")
        }
        // this.classList.remove("bcp","bcr")
        console.dir(this)
        this.classList.add("bcb")
      }
    }
  </script>
</body>
</html>